package com.ruoyi.smart.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.smart.domain.SmartPlanTask;
import com.ruoyi.smart.service.ISmartPlanTaskService;
import com.ruoyi.common.utils.poi.ExcelUtil;

/**
 * 计划任务Controller
 * 
 * @author minwei
 * @date 2022-04-26
 */
//@Api("计划任务")
@RestController
@RequestMapping("/smart/planTask")
public class SmartPlanTaskController extends BaseController
{
    @Autowired
    private ISmartPlanTaskService smartPlanTaskService;

    /**
     * 查询计划任务列表
     */
    @PreAuthorize("@ss.hasPermi('smart:planTask:list')")
    @GetMapping("/list")
    //@ApiOperation("查询计划任务列表")
    public AjaxResult list(SmartPlanTask smartPlanTask)
    {
        List<SmartPlanTask> list = smartPlanTaskService.selectSmartPlanTaskList(smartPlanTask);
        return AjaxResult.success(list);
    }

    /**
     * 导出计划任务列表
     */
    @PreAuthorize("@ss.hasPermi('smart:planTask:export')")
    @Log(title = "计划任务", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SmartPlanTask smartPlanTask)
    {
        List<SmartPlanTask> list = smartPlanTaskService.selectSmartPlanTaskList(smartPlanTask);
        ExcelUtil<SmartPlanTask> util = new ExcelUtil<SmartPlanTask>(SmartPlanTask.class);
        util.exportExcel(response, list, "计划任务数据");
    }

    /**
     * 获取计划任务详细信息
     */
    @PreAuthorize("@ss.hasPermi('smart:planTask:query')")
    @GetMapping(value = "/{id}")
    //@ApiOperation("获取计划任务详细信息")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(smartPlanTaskService.selectSmartPlanTaskById(id));
    }

    /**
     * 新增计划任务
     */
    @PreAuthorize("@ss.hasPermi('smart:planTask:add')")
    @Log(title = "计划任务", businessType = BusinessType.INSERT)
    @PostMapping
    //@ApiOperation("新增计划任务")
    public AjaxResult add(@RequestBody SmartPlanTask smartPlanTask)
    {
        return toAjax(smartPlanTaskService.insertSmartPlanTask(smartPlanTask));
    }

    /**
     * 修改计划任务
     */
    @PreAuthorize("@ss.hasPermi('smart:planTask:edit')")
    @Log(title = "计划任务", businessType = BusinessType.UPDATE)
    @PutMapping
    //@ApiOperation("修改计划任务")
    public AjaxResult edit(@RequestBody SmartPlanTask smartPlanTask)
    {
        return toAjax(smartPlanTaskService.updateSmartPlanTask(smartPlanTask));
    }

    /**
     * 删除计划任务
     */
    //@ApiOperation("删除计划任务")
    @PreAuthorize("@ss.hasPermi('smart:planTask:remove')")
    @Log(title = "计划任务", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(smartPlanTaskService.deleteSmartPlanTaskByIds(ids));
    }
}
